package com.jie.langlangmall.portal.controller;

import com.jie.langlangmall.common.api.CommonResult;
import com.jie.langlangmall.portal.domain.PmsProductComment;
import com.jie.langlangmall.portal.service.ProductCommentService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author Jie
 * @Date 2024/11/29
 * @Email 3217998214@qq.com
 * @Description 评论
 */
@RestController
@RequestMapping("/product/comment")
public class ProductCommentController {

    @Autowired
    private ProductCommentService productCommentService;

    @Operation(summary = "获取指定商品的评论列表")
    @GetMapping("/{productId}")
    public CommonResult<List<PmsProductComment>> getProductComment(@PathVariable("productId") Long productId) {
        List<PmsProductComment> productCommentList = productCommentService.getProductComment(productId);
        return CommonResult.success(productCommentList);
    }

    @Operation(summary = "添加评论")
    @PostMapping("/add")
    public CommonResult<?> addProductComment(@RequestBody PmsProductComment productComment) {
        productCommentService.addProductComment(productComment);
        return CommonResult.success();
    }

}
